package org.hackystat.sdsa.analyzer.control.compressor;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.hackystat.sdsa.analyzer.model.activity.Activity;
import org.junit.Test;

/**
 * Tests the compressor container that merges all compressors together.
 * 
 * @author hongbing
 *
 */
public class TestCompressorContainer extends CompressorTestCommon {
  /** Activity List. */
  private List<Activity> activityList;
  /** Container. */
  private CompressorContainer container;
  
  /**
   * Prepares testing environment. 
   * 
   * @throws Exception If problem in testing.
   */
  @Override public void setUp() throws Exception {
    super.setUp();  
    this.container = new CompressorContainer();
    this.activityList = new ArrayList<Activity>();
  }
  
  /**
   * Test Behaviors of the compressor holder.
   * 
   * @throws Exception If problem occurs.
   */
  @Test public void testEmptyActivity() throws Exception {
    this.container.compress(this.activityList);
    assertEquals("Empty number of activities", 0, activityList.size());
    
  }
  
  /**
   * Test edit activity.
   * 
   * @throws Exception If problem occurs.
   */
  @Test public void testEditActivity() throws Exception {
    // Doc edit only
    activityList.addAll(super.docActivityList);
    assertEquals("Test size before doc edit compression", 4, activityList.size());
    this.container.addCompressor(new EditCompressor());
    
    this.container.compress(activityList);
    assertEquals("Test size after doc edit compression", 2, activityList.size());
    
    // Prod edit activity. 
    activityList.addAll(super.prodActivityList);
    assertEquals("Test size before prod edit compression", 7, activityList.size());
    this.container.compress(activityList);
    assertEquals("Test size after prod edit compression", 4, activityList.size());
  }
}
